package iofile;

import java.io.File;
import java.io.IOException;

public class FileCreate {

    public static void main(String[] args) {

    }

    //文件创建方式1 new File(String pathname)
    public void create_01(){
        String filePath = "";
        File file = new File(filePath);

        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //文件创建方式2 new File(File parent, String child)
    public void create_02(){
        File parentFile = new File("parentFilePath");
        String fileName = "";
        File file = new File(parentFile, fileName);
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //文件创建方式03 new File(String parent, String child)
    public void create_03(){
        String parentFilePath = "";
        String fileName = "";
        File file = new File(parentFilePath, fileName);
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
